package com.squirrel.michale;

import java.util.Arrays;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/2/28 7:30 AM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class LeetCode2274 {

    public int maxConsecutive(int bottom, int top, int[] special) {
        Arrays.sort(special);
        int max = 0;
        int temp = 0;
        temp = special[0] - bottom ;
        max = max > temp ? max : temp;
        for (int i = 0; i < special.length-1; i++) {
            temp = special[i + 1] - special[i]-1 ;
            max = max > temp ? max : temp;
        }
        temp = top - special[special.length-1];
        max = max > temp ? max : temp;
        return max;
    }

    public static void main(String[] args) {
        LeetCode2274 leetCode2274 = new LeetCode2274();


        int  bottom = 2, top = 9;
        int[] special = new int[]{4, 6};
        System.out.println(leetCode2274.maxConsecutive(bottom, top, special));
    }
}
